package com.jiefutong.zyt;

import android.app.Activity;
import android.app.Application;

import com.jiefutong.zyt.http.Url;
import com.jiefutong.zyt.http.XCRRestProvider;
import com.sobot.chat.SobotApi;
import com.umeng.commonsdk.UMConfigure;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import java.util.ArrayList;
import java.util.List;

import cn.jpush.android.api.JPushInterface;

/**
 * @Author l
 * @Date 2018/10/12
 */
public class BaseApp extends Application {
    public static List<Activity> mActivitys=new ArrayList<>();
    /**应用实例**/
    private static BaseApp instance;
    /**
     *  获得实例
     * @return
     */
    public static BaseApp getInstance(){
        if(instance==null){
            instance=new BaseApp();
        }
        return instance;
    }
    @Override
    public void onCreate() {
        super.onCreate();
        XCRRestProvider.getInstance().init(Url.BASE);
        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "5bc69832f1f556660400027e");
        PlatformConfig.setWeixin("wxee74f601dee11cdd", "866d02dbc8e6a487449d06ff4a8a5d66");
        PlatformConfig.setQQZone("1107910470", "uknRFvdwjzkzArci");
        UMShareAPI.get(this);
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        //初始化智齿平台
        SobotApi.initSobotSDK(getApplicationContext(), "82c234e35777444786715c6bad03ce41", "");
    }

    public static void addActivity(Activity activity){
        mActivitys.add(activity);

    }
    public static void removeActivity(Activity activity){
        mActivitys.remove(activity);


    }

    public static void finishAll(){
        for(Activity a:mActivitys){
            if(!a.isFinishing()){
                a.finish();
            }
        }
        // System.exit(0);
    }
}
